/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.dswII.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itsc.dswII.model.Beneficio;

/**
 *
 * @author Lenovo-user
 */
@Stateless
public class BeneficioDao extends AbstractDao<Beneficio> implements BeneficioDaoLocal {

    @PersistenceContext(unitName = "EmploymentYuri2JEE-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public BeneficioDao() {
        super(Beneficio.class);
    }

    public Boolean findDuplicity(Beneficio benef) {
        Query q = em.createNamedQuery("Beneficio.findDuplicity");
        q.setParameter("id", benef.getId());
        q.setParameter("hora", benef.getHora());
        q.setParameter("fecha", benef.getFecha());
        return !q.getResultList().isEmpty();

    }
    public List<Beneficio> findByBeneficio(Beneficio persona) {
       Query q = em.createNamedQuery("Beneficio.findByFecha");
        q.setParameter("fecha", persona.getFecha());
        return q.getResultList();
    }
}
